<?php


namespace app\web\controller;


use app\common\lib\Util;
use think\Controller;

class Agreement extends Controller
{
    /**
     * 隐私政策
     */
    public function privacy()
    {
        $ver = input('v/s', '');
        $newVersion = '2.9.0';
        $htmlName = 'privacy11';
        if ($ver !== '')
        {
            [$a1, $a2, $a3] = explode('.', $ver);
            [$b1, $b2, $b3] = explode('.', $newVersion);
            if ($a1 < $b1 || ($a1 === $b1 && $a2 < $b2) || ($a1 === $b1 && $a2 === $b2 && $a3 < $b3))
            {
                $htmlName = 'privacy9';
            } else if (Util::CheckAppVersion('2.9.4', $ver) === '同' || Util::CheckAppVersion('2.9.5', $ver) === '同')
            {
                $htmlName = 'privacy10';//去掉了神策sdk的描述
            } else if (Util::CheckAppVersion('2.9.6', $ver) === '同' || Util::CheckAppVersion('2.9.6', $ver) === '大')
            {
                $htmlName = 'privacy11';//增加了神策sdk的描述
            }

        }
//        $res = Util::androidVersion('2.2.0');
//        $this->assign('version', $res);
//        $headers = $this->request->header();
//        $app_type = $headers['app-type'] ?? '';
//        $this->assign('appType', $app_type);
        return $this->fetch($htmlName, ['v' => $ver]);
    }

    /**
     * 隐私政策简易版
     */
    public function privacy_easy()
    {
        return $this->fetch();
    }

    /**
     * 服务协议
     */
    public function service()
    {
        return $this->fetch();
    }

    /**
     * 占星师平台注册协议
     */
    public function privacy_astrologer()
    {
        return $this->fetch();
    }

    /**
     * 准了咨询师app隐私政策
     */
    public function privacy_astrologer_privacy()
    {
        return $this->fetch();
    }


    /**
     * 占星师平台能力等级规则
     */
    public function rule_astrologer()
    {
        return $this->fetch();
    }

    /**
     * 问答-占星能力分细则
     */
    public function rule_astro_grade()
    {
        return $this->fetch();
    }

    /**
     * 问答-塔罗能力分细则
     */
    public function rule_tarot_grade()
    {
        return $this->fetch();
    }

    /**
     * 占星师平台服务条款
     */
    public function service_astrologer()
    {
        return $this->fetch();
    }

    public function privatearea_service()
    {
        return $this->fetch();
    }

    /**
     * 用户端-引导问题
     */
    public function guide()
    {
        $is_huawei = input('is_huawei', 0);
        return $this->fetch('guide', ['is_huawei' => $is_huawei]);
    }

    /**
     * ios 订阅及会员协议
     */
    public function subscribe()
    {
        $isNew = Util::CheckAppVersion('2.10.5') !=='小';

        return $this->fetch('subscribe', ['isNew' => $isNew]);
    }

    /**
     * 安卓会员协议
     */
    public function vip()
    {
        return $this->fetch('vip');
    }


    /**
     * 1.1.0 准了咨询师App-成长值增减规则
     * https://local-beta-wechat.goddessxzns.com/web/astrologer_growth_rule.html
     * @return mixed
     */
    public function astrologer_growth_rule()
    {
        return $this->fetch('astrologer_app_common_img_agreement', [
            'title' => '成长值增减规则',
            'img' => 'https://oss.goddessxzns.com/astrologer_app/1.1.0/img/agreement/astrologer_growth_rule.jpg',
        ]);
    }

    /**
     * 1.1.0 准了咨询师App-问答规则
     * https://local-beta-wechat.goddessxzns.com/web/astrologer_sharing_rule.html
     * @return mixed
     */
    public function astrologer_sharing_rule()
    {
        return $this->fetch('astrologer_app_common_img_agreement', [
            'title' => '问答规则',
            'img' => 'https://oss.goddessxzns.com/astrologer_app/1.1.0/img/agreement/astrologer_sharing_rule.jpg',
        ]);
    }

    /**
     * 准了咨询师App（1.2.0）或者 私域提现平台（1.0.0）-提现规则和发票须知
     * https://local-beta-wechat.goddessxzns.com/web/agreement/astrologer_withdraw_guide.html
     * @return mixed
     */
    public function astrologer_withdraw_guide()
    {
        return $this->fetch('astrologer_app_common_img_agreement', [
            'title' => '提现规则和发票须知',
            'img' => 'https://oss.goddessxzns.com/astrologer_app/1.2.0/astrologer_withdraw_guide_1.jpg',
        ]);
    }

    /**
     * 私域提现平台（1.0.0）-咨询师注册协议
     * https://local-beta-wechat.goddessxzns.com/web/agreement/private_area_astrologer_registry_agreement.html
     * @return mixed
     */
    public function private_area_astrologer_registry_agreement()
    {
        return $this->fetch('astrologer_app_common_img_agreement', [
            'title' => '星座女神咨询师平台注册协议',
            'img' => 'https://oss.goddessxzns.com/private_area/withdraw_web/1.0.0/private_area_astrologer_registry_agreement.jpg',
        ]);
    }

    /**
     * 准了咨询师App（1.2.0）或者 私域提现平台（1.0.0）-发票详情（android看不了发票）【注意pdf_url需要进行url encode】
     * https://local-beta-wechat.goddessxzns.com/web/agreement/astrologer_app_invoice_view.html?pdf_url=https%3A%2F%2Foss.goddessxzns.com%2Fupload%2Finvoice%2F20240120%2Fae48e7007418ed68c83df2107031fce8.pdf%3FOSSAccessKeyId%3DLTAI5tBdbBvZZzqreXhHn9eF%26Expires%3D1707515655%26Signature%3DNQMs43qx1UKUR%252B%252BEjWIepiwa3z4%253D
     * @return mixed
     */
    public function astrologer_app_invoice_view()
    {
        $pdf_url = input('pdf_url/s', '');
        $pdf_url = base64_decode($pdf_url, true);
        return $this->fetch('astrologer_app_invoice_view', [
            'title' => '发票详情',
            'pdf_url' => $pdf_url,
        ]);
    }

    /**
     * 私域实物：海南能量拾叁珠宝有限公司服务协议
     */
    public function private_area_service2024()
    {
        return $this->fetch();
    }
}
